<template>
    <el-dialog :model-value="modelValue" @update:model-value="$emit('update:modelValue', $event)"
        :title="isEdit ? '编辑员工' : '添加员工'" width="50%">
        <el-form :model="formData" label-width="120px">
            <el-form-item label="姓名" required>
                <el-input v-model="formData.name" />
            </el-form-item>
            <el-form-item label="账号" required>
                <el-input v-model="formData.account" />
            </el-form-item>
            <el-form-item label="行政职务">
                <el-input v-model="formData.position" />
            </el-form-item>
            <el-form-item label="所属部门">
                <el-input v-model="formData.department" />
            </el-form-item>
            <el-form-item label="组织关系">
                <el-input v-model="formData.orgRelation" />
            </el-form-item>
            <el-form-item label="是否主管">
                <el-checkbox v-model="formData.isManager" />
            </el-form-item>
            <el-form-item label="直属领导">
                <el-input v-model="formData.supervisor" />
            </el-form-item>
            <el-form-item label="性别">
                <el-radio-group v-model="formData.gender">
                    <el-radio label="男" />
                    <el-radio label="女" />
                </el-radio-group>
            </el-form-item>
            <el-form-item label="年龄">
                <el-input-number v-model="formData.age" :min="18" :max="70" />
            </el-form-item>
            <el-form-item label="员工状态">
                <el-select v-model="formData.status">
                    <el-option label="在职" value="在职" />
                    <el-option label="离职" value="离职" />
                </el-select>
            </el-form-item>
            <el-form-item label="访问状态">
                <el-select v-model="formData.accessStatus">
                    <el-option label="正常" value="正常" />
                    <el-option label="禁用" value="禁用" />
                </el-select>
            </el-form-item>
            <el-form-item label="手机号">
                <el-input v-model="formData.phone" />
            </el-form-item>
            <el-form-item label="邮箱">
                <el-input v-model="formData.email" />
            </el-form-item>
        </el-form>
        <template #footer>
            <el-button @click="$emit('update:modelValue', false)">取消</el-button>
            <el-button type="primary" @click="handleConfirm">确定</el-button>
        </template>
    </el-dialog>
</template>

<script setup>
defineProps({
    modelValue: Boolean,
    formData: Object,
    isEdit: Boolean
})

const emit = defineEmits(['update:modelValue', 'submit'])

const handleConfirm = () => {
    emit('submit')
    emit('update:modelValue', false)
}
</script>